<!DOCTYPE HTML>
<html>
<head>
<title>改变 MsgBox 的按钮名称 - 脚本示例 | AutoHotkey</title>
<meta name="description" content="This script changes the names of the buttons in a MsgBox dialog using a timer." />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>改变 MsgBox 的按钮名称</h1>

<p>这是个可运行示例脚本, 它使用计时器改变 MsgBox 对话框中按钮的名称. 尽管改变了按钮名称, 但 IfMsgBox 命令中仍需要引用它们原始的按钮名称表示的按钮.
</p>
<p><a href="MsgBoxButtonNames.ahk">下载此脚本</a> &nbsp;| &nbsp;<a href="index.htm">其他示例脚本</a> &nbsp;| &nbsp;<a href="../AutoHotkey.htm">主页</a></p>

<pre class="NoIndent">#SingleInstance
SetTimer, ChangeButtonNames, 50 
MsgBox, 4, Add or Delete, Choose a button:
IfMsgBox, YES 
    MsgBox, You chose Add. 
else 
    MsgBox, You chose Delete. 
return 

ChangeButtonNames: 
IfWinNotExist, Add or Delete
    return  <em>; Keep waiting.</em>
SetTimer, ChangeButtonNames, Off 
WinActivate 
ControlSetText, Button1, &amp;Add 
ControlSetText, Button2, &amp;Delete 
return
</pre>
</body>
</html>